import {getAllList, getList, add, deleteById} from '@/api/Achievement'


const performance = {
    state: {
        treeList: [],
        allList: []
    },

    getters: {
        treeList: state => state.treeList,
        allList: state => state.allList
    },

    mutations: {
        SET_TREE_LIST(state, treeList){
            state.treeList = treeList
        },

        SET_ALL_LIST(state, allList){
            state.allList = allList
        }
    },

    actions: {
        getAllList({commit}){
            return new Promise((resolve, reject) => {
                getAllList().then(res => {
                    commit('SET_ALL_LIST', res.data.data.list)
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },

        getList({commit}){
            return new Promise((resolve, reject) => {
                getList().then(res => {
                    commit('SET_TREE_LIST', res.data.data.list)
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
    }
}

export default performance